package com.wch.user.config;

import com.wch.user.filter.JwtFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 配置拦截器类
 * author WanChengHe 20190506
 */
@Configuration
@ComponentScan({"com.wch.user.filter"})
public class ApplicationConfig extends WebMvcConfigurationSupport {

    @Autowired
    private JwtFilter jwtFilter;


    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
       registry.addInterceptor(jwtFilter)     //添加拦截器
               .addPathPatterns("/**")       //全部拦截
               .excludePathPatterns("/**/login");  //排除登录的
    }
}
